<template>
    <div>
        <button @click="loadData">点我获取请求</button>
        <button @click="carData">点我获取第二个数据</button>
    </div>
</template>
<script>
    import axios from 'axios'
    export default {
        name: 'App',

        data() {
            return {}
        },
        methods: {
            loadData() {
                //获取中间代理从而实现中转获取代理数据
                //缺点:会和当前端口的数据重合,若同名返回数据矛盾,非请求服务器数据
                axios.get('http://localhost:8080/test/students').then(
                    response => {
                        console.log('请求成功' + JSON.stringify(response.data))
                    },
                    error => {
                        console.log('请求失败' + error);
                    }
                )
            }, carData() {
                axios.get('http://localhost:8080/demo/cars').then(
                    response => {
                        console.log('请求成功' + JSON.stringify(response.data))
                    },
                    error => {
                        console.log('请求失败' + error);
                    }
                )
            }
        },
    }
</script>
<style>
</style>